var DataGridUtil ={
    Delete : function(url, datagridName){//执行删除
        dataGridDelete(url, datagridName);
    }
}

function  dataGridDelete(url, gridName){
    try{
        if (!gridName.startsWith("#")){
            gridName = "#" + gridName;
        }
        var ids = new Array();
        var selectRows  = $(gridName).datagrid("getSelections");
        $.each(selectRows,function(i,n){
            ids.push(n.id);
        });
        if (ids.length==0){
            layer.msg("请选择删除项！");
        }else {
            layer.confirm('确定删除选中项吗??', {icon: 3, title:'提示'}, function(index){
                //do something
                dataGridDeleteCallback(ids,url,gridName);
                layer.close(index);
            });
        }
    }catch (e) {
        layer.msg("脚本错误:"+e);
    }
}

function dataGridDeleteCallback(ids,url,gridName){
    $.post(url,{'ids':ids.toString()},function (data) {
        if(!data.success == true){
            // top.Dialog.alert("错误",data.error,"error");
            layer.msg("错误！");
        }else{
            layer.msg("删除成功!");
            $(gridName).datagrid("reload");
        }
    },"json");
}
